package com.jacobson.huobi.mvp.presenter

import com.jacobson.core.di.annotation.ActivityScope
import com.jacobson.core.mvp.BasePresenter
import com.jacobson.core.widget.storage.GlobalStorage
import com.jacobson.huobi.common.constants.CommonConstant
import com.jacobson.huobi.mvp.contract.SymbolContract
import com.jacobson.huobi.utils.NetworkHelper
import com.jacobson.huobi.websocket.ProtocolFactory
import com.jacobson.huobi.websocket.WebsocketManager
import javax.inject.Inject

@ActivityScope
class SymbolPresenter @Inject constructor(
    view: SymbolContract.View,
    model: SymbolContract.Model
) : BasePresenter<SymbolContract.View, SymbolContract.Model>(view, model),
    SymbolContract.Presenter {
    override fun updateSymbolList(marketName: String) {
        WebsocketManager.sendMessage(ProtocolFactory.ofSubscribe())
    }

    override fun onStart() {
        if (NetworkHelper.isNetworkAvailable()) {
            view?.onNetworkUnavailable()
        }
    }
}